package com.secret.chain.secretchain.controller.wx;

import com.secret.chain.secretchain.domain.entity.Answer;
import com.secret.chain.secretchain.result.Result;
import com.secret.chain.secretchain.service.AnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wx/answer")
@CrossOrigin
public class AnswerController {
    @Autowired
    private AnswerService answerService;
    @GetMapping("{problemId}")
    public Result<Answer> queryByProblemId(@PathVariable Integer id) {
        Result<Answer> result = answerService.queryByProblemId(id);
        return result;
    }

    @PutMapping
    public Result update(@RequestBody Answer answer) {
        return answerService.update(answer);
    }

    @PostMapping
    public Result save(@RequestBody Answer answer) {
        return answerService.save(answer);
    }

    @DeleteMapping
    public Result delete(Integer id) {
        return answerService.delete(id);
    }
}
